/*
 * MyGWT User Extensions
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package net.mygwt.ux.samples.explorer.client;

import net.mygwt.ui.client.widget.Info;
import net.mygwt.ui.client.widget.WidgetContainer;
import net.mygwt.ui.client.widget.layout.TableLayout;
import net.mygwt.ux.client.event.ValueChangeEvent;
import net.mygwt.ux.client.event.ValueChangeListener;
import net.mygwt.ux.client.widgets.TextBox;

/**
 * 
 * @author Damien Ferrand
 * 
 */
public class TextBoxPage extends Page {

	protected void createWidget(WidgetContainer container) {
		TableLayout tl = new TableLayout(2);
		tl.setCellSpacing(5);
		container.setLayout(tl);

		TextBox normalTextBox = new TextBox();
		container.add(normalTextBox);
		container.addText("Normal TextBox");

		TextBox passwordTextBox = new TextBox(0, TextBox.PASSWORD);
		container.add(passwordTextBox);
		container.addText("Password TextBox");

		TextBox uppercaseTextBox = new TextBox(0, TextBox.UPPERCASE);
		container.add(uppercaseTextBox);
		container.addText("Uppercase TextBox");

		TextBox lowercaseTextBox = new TextBox(0, TextBox.LOWERCASE);
		container.add(lowercaseTextBox);
		container.addText("Lowercase TextBox");

		TextBox valueChangeTextBox = new TextBox();
		valueChangeTextBox.addValueChangeListener(new ValueChangeListener() {
			public void valueChanged(ValueChangeEvent valueChangeEvent) {
				Info.show("Value changed", "before: {0}<br>after: {1}",
						new String[] { valueChangeEvent.getPreviousValue(),
								valueChangeEvent.getNewValue() });
			}
		});
		container.add(valueChangeTextBox);
		container.addText("ValueChangeEvent TextBox");
	}

}
